package com.example.myletcodelearing.fbnq

/**
 * @author tgw
 * @date 2022/8/4
 * @describe 斐波那契 递归
 */


fun main(array: Array<String>) {
    println("斐波那契：开始")

    (0..40).forEach {
        var value =fbnq(it)
        println("值：$value")
    }

    var a = 100000
    var b = 200000
    var num = a
    var index = 0
    while (num<b){
        num = (num+num*0.02).toDouble().toInt()
        index++
    }
    println("利率计算值：$num")
    println("次数：$index")
}

fun fbnq(a:Int):Int{
   if (a<2){
       return 1
   }
    return fbnq(a-1)+ fbnq(a-2)
}

